#include <pic.h>
#include <math.h>
#include <stdio.h>


const unsigned int adcd[40]={847,830,813,794,775,756,735,714,692,670,648,625,602,579,556,534,511,489,467,445,424,404,384,365,
347,329,312,296,280,265,237,224,212,201,190,179,169,160,151,143};
const signed char temper[40]={-7,-5,-3,-1,1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,55,57,59,61,63,65,67,69,71};


unsigned int AdcToTemp (unsigned int data)
{	unsigned char pointer = 0;
	unsigned int dif_temp,dif_adc,dif;

	while (data< adcd[++pointer]);
	// here we knowing number of the line 
		dif_adc= adcd[pointer-1]-adcd[pointer];  
		dif=data - adcd[pointer];			
		dif*=200;
		dif/=dif_adc;
		dif = temper[pointer]*100 - dif;
		return dif ;
};
